package org.dtrd.modules.evaluation.entity.po;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Getter;
import lombok.Setter;
import org.dtrd.modules.evaluation.entity.bean.AdknowlDetail;

import java.util.Date;
import java.util.StringJoiner;


/**
 * <p>
 * 患者知识量表（ADKnowl）
 * </p>
 *
 * @author QR
 * @since 2021-12-15
 */
@Getter
@Setter
@TableName("dtrd_ent_evaluation_rd_adknowl")
public class DtrdEntEvaluationRdAdknowl {

    @TableId(value = "data_id", type = IdType.AUTO)
    private Integer dataId;

    @TableField("is_del")
    @TableLogic
    private Integer isDel;

    /**
     * 患者ID
     */
    @TableField("patient_id")
    private Integer patientId;

    /**
     * 创建时间
     */
    @TableField("create_time")
    private Date createTime;

    /**
     * 输入内容
     */
    @TableField("input")
    private String input;

    /**
     * 总分
     */
    @TableField("score")
    private Integer score;

    /**
     * 输出内容
     */
    @TableField("output")
    private String output;

    public DtrdEntEvaluationRdAdknowl init() {
        isDel = 0;
        createTime = new Date();
        return this;
    }

    public DtrdEntEvaluationRdAdknowl parseFromDto(AdknowlDetail dto) {
        dataId = dto.getDataId();
        patientId = dto.getPatientId();
        StringJoiner joiner = new StringJoiner(",");
        dto.getInput().forEach(answer -> joiner.add(answer+""));
        input = joiner.toString();
        score = dto.getScore();
        output = dto.getOutput();
        return this;
    }


}
